import Vue from 'vue'
import Vuex from 'vuex'
import VuexPersist from 'vuex-persist'

Vue.use(Vuex);

let state = {//数据存储
    // count:10,
    // todos: [
    //     { id: 1, text: '水果类', done: true },
    //     { id: 2, text: '苹果', done: true },
    //     { id: 3, text: '苹果', done: false}
    // ]
    BreadcrumbMeat:[],//面包屑
    
}

let getters = { //state的计算属性,页面需要对state进行一些处理时调用
    // getCount:state=>{
    //     return state.count
    // },

}

let mutations = { //修改数据的唯一路径
    repMeat (state,data) {//变更面包屑
        console.log(state,data, 'vuex')
    }

}

let actions = { //处理异步
    // getDelCount({commit},val){
    //     commit('delCount',val)
    // }

}

let vuexLocal = new VuexPersist({
    storage: window.sessionStorage  // 可选，localStorage/sessionStorage/indexDB
})

export default new Vuex.Store({ state, getters, mutations, actions, plugins: [vuexLocal.plugin]})